package com.rbs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.rbs.entity.AdminUser;
import com.rbs.mapper.AdminUserMapper;
import com.rbs.service.IAdminUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author lisl
 * @since 2024-04-07
 */
@Service
public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser> implements IAdminUserService {
    @Autowired
    private AdminUserMapper adminUserMapper;

    @Override
    public boolean findSameUsername(AdminUser adminUser) {
        LambdaQueryWrapper<AdminUser> wrapper=new LambdaQueryWrapper<AdminUser>().eq(AdminUser::getUsername,adminUser.getUsername());
        boolean flag=adminUserMapper.exists(wrapper);
        return flag;
    }

    @Override
    public List<AdminUser> findByUserName(AdminUser adminUser) {
        LambdaQueryWrapper<AdminUser> wrapper=new LambdaQueryWrapper<AdminUser>().like(adminUser.getUsername()!=null,AdminUser::getUsername,adminUser.getUsername());
        List<AdminUser> uList=adminUserMapper.selectList(wrapper);
        return uList;
    }

    @Override
    public List<AdminUser> findByIdm(AdminUser adminUser) {
        LambdaQueryWrapper<AdminUser> wrapper=new LambdaQueryWrapper<AdminUser>().like(adminUser.getId()!=null,AdminUser::getId,adminUser.getId());
        List<AdminUser> iList=adminUserMapper.selectList(wrapper);
        return iList;
    }

}
